<?php
/**
 * Created by PhpStorm.
 * User: zgh
 * Date: 2021-07-28
 * Time: 17:38
 */

namespace app\common\model;


use app\common\item\UploadLoader;
use think\Model;

class UploadModel extends Model
{
    protected $autoWriteTimestamp = true;

    const tableName = 'upload';

    public function getCreateTimeAttr($value)
    {
        return date("Y-m-d H:i:s", $value);
    }

    public function getPlatformTextAttr($value, $data)
    {
        if ($data['platform'] == UploadLoader::PLATFORM_LOCAL) {
            return '本地';
        } elseif ($data['platform'] == UploadLoader::PLATFORM_COS) {
            return '腾讯云';
        } elseif ($data['platform'] == UploadLoader::PLATFORM_OSS) {
            return '阿里云';
        }
    }


    public function getSizeTextAttr($value, $data)
    {
        return format_bytes($data['size']);
    }


}